<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery.min.js"></script>

<script type="text/javascript">
	
$(function(){
	//通过Ajax访问后端数据
	$.ajax({
		url:"getusers",
		dataType:"json",
		success:function(data){
			//alert(data.length);
			for(var i=0;i<data.length;i++){
				$("#ul_user").append("<li>"+data[i].uname+"</li>");
				
			}
		}
	})
})

function searchUser(){
	var userid=$("#userid").val();
	//通过Ajax访问后端数据
	$.ajax({
		url:"getUser",
		data:{id:userid},
		dataType:"json",
		success:function(data){
			$("#ul_user").html("");
			$("#ul_user").append("<li>"+data.uname+"</li>");
				
		}
	})
	
}

</script>
</head>
<body>
<h2>用户列表</h2>
<ul id="ul_user">

</ul>

请输入用户ID：<input type="text" id="userid"/><input type="button" value="查询" onclick="searchUser()"/>
</body>
</html>